package com.spider.service;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import org.apache.hadoop.hbase.client.Result;

import com.spider.dao.HBaseDAOImp;
import com.spider.dao.HBaseDao;
import com.spider.utils.ResolveHtml;

public class Process {
	
	private HBaseDao dao = new HBaseDAOImp();
	
	public static void main(String[] args) {
		Process process = new Process();
		ResolveHtml htmlResolve = new ResolveHtml();
//		Result result = process.dao.getRow("Test","63727281");
//		System.out.println(new String(result.getValue("base".getBytes(), "content".getBytes())));
//		htmlResolve.resolve(new File("./a"));
//		PrintWriter pw = null;
//		try {
//			pw = new PrintWriter(new FileWriter("./a"));
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		List<Result> resultList = process.dao.getRows("Test", "63");
//		List<String> strList = new ArrayList();
//		for(int i = 0;i < resultList.size();i++) {
//			String content = new String(resultList.get(i).getValue("base".getBytes(), "content".getBytes()));
//			System.out.println(content);
			//			pw.write(content);
//			pw.flush();
//			pw.close();
//		}
	

		List<Result> resultList = process.dao.getRows("html", "content");
		List<Result> resultList2 = process.dao.getRows("html0714", "content");
		for(int i = 0;i < resultList.size();i++) {
			String html = new String(resultList.get(i).getValue("base".getBytes(), "content".getBytes()));
			htmlResolve.resolve(html);
		}
		for(int i = 0;i < resultList2.size();i++) {
			String html = new String(resultList2.get(i).getValue("base".getBytes(), "content".getBytes()));
			htmlResolve.resolve(html);
		}
	}
}
